
package net.swa.dewei.web.action;

import java.util.List;
import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Required;
import net.sf.json.JSONArray;
import net.swa.dewei.beans.entity.MenDian;
import net.swa.dewei.beans.vo.MendDistr;
import net.swa.dewei.service.MendDistributionService;
import net.swa.system.service.ICommonService;
import net.swa.system.util.annotation.Log;
import net.swa.system.web.action.AbstractBaseAction;

/**门店分布查询 StatisAction.java  Action**/
public class MendDistributionAction extends AbstractBaseAction
{
    private static final long serialVersionUID = -9167064623097370397L;

    private final Logger log = Logger.getLogger(MendDistributionAction.class);

    /** 公用方法接口 */
    private ICommonService commonService;

    private MendDistributionService mendDistributionService;

    private Boolean chargeStation;

    private Boolean weixiu;

    private Boolean xiaoshou;

    /**门店json 数组**/
    private String mendsJson;

    /**门店按省分布数据**/
    private String distrJson;

    @Log(description = "进入门店分布查询")
    public String queryMendDistibution()
    {
//        chargeStation = true;
//        weixiu = true;
//        xiaoshou = true;

        List<MenDian> obj = mendDistributionService.queryMend(chargeStation, weixiu, xiaoshou);
        JSONArray ja = JSONArray.fromObject(obj);
        mendsJson = ja.toString();

        List<MendDistr> distr = mendDistributionService.queryMendDistr(chargeStation, weixiu, xiaoshou);

        JSONArray ja2 = JSONArray.fromObject(distr);
        distrJson = ja2.toString();

        log.debug("进入门店分布查询,distrJson is \n " + distrJson + "  \n ,mendsJson is \n" + mendsJson);
        return "queryMendDistibution";
    }

    public String queryDistrData() throws Exception
    {
//        Map<String, Object> map = new HashMap<String, Object>();
//        List<MenDian> obj = mendDistributionService.queryMend(chargeStation, weixiu, xiaoshou);
//        map.put("mendsJson", obj);
//
//        List<MendDistr> distr = mendDistributionService.queryMendDistr(chargeStation, weixiu, xiaoshou);
//        map.put("distrJson", distr);
//
//        log.debug("进入门店分布查询,distrJson is \n " + obj + "  \n ,mendsJson is \n" + distr);
//
//        outJson(map);
//        return null;
        List<MenDian> obj = mendDistributionService.queryMend(chargeStation, weixiu, xiaoshou);
        JSONArray ja = JSONArray.fromObject(obj);
        mendsJson = ja.toString();

        List<MendDistr> distr = mendDistributionService.queryMendDistr(chargeStation, weixiu, xiaoshou);

        JSONArray ja2 = JSONArray.fromObject(distr);
        distrJson = ja2.toString();

      //  log.debug("进入门店分布查询,distrJson is \n " + distrJson + "  \n ,mendsJson is \n" + mendsJson);
        return "queryMendDistibution";
    }

    public ICommonService getCommonService()
    {
        return commonService;
    }

    @Required
    @Resource
    public void setCommonService(ICommonService commonService)
    {
        this.commonService = commonService;
    }

    @Required
    @Resource
    public void setMendDistributionService(MendDistributionService mendDistributionService)
    {
        this.mendDistributionService = mendDistributionService;
    }

    public Boolean getChargeStation()
    {
        return chargeStation;
    }

    public void setChargeStation(Boolean chargeStation)
    {
        this.chargeStation = chargeStation;
    }

    public Boolean getWeixiu()
    {
        return weixiu;
    }

    public void setWeixiu(Boolean weixiu)
    {
        this.weixiu = weixiu;
    }

    public Boolean getXiaoshou()
    {
        return xiaoshou;
    }

    public void setXiaoshou(Boolean xiaoshou)
    {
        this.xiaoshou = xiaoshou;
    }

    public String getMendsJson()
    {
        return mendsJson;
    }

    public void setMendsJson(String mendsJson)
    {
        this.mendsJson = mendsJson;
    }

    public String getDistrJson()
    {
        return distrJson;
    }

    public void setDistrJson(String distrJson)
    {
        this.distrJson = distrJson;
    }

}
